//
//  NSString+Components.m
//  MindBox
//
//  Created by MS on 16-1-14.
//  Copyright (c) 2016年 Lemon. All rights reserved.
//

#import "NSString+Components.h"

@implementation NSString (Components)

+(NSMutableArray *)stringWithStr:(NSString *)nsstring ComponentStr:(NSString *)componentStr startSubStr:(NSString *)starSubStr
{
    NSArray * imageStrArray = [nsstring componentsSeparatedByString:componentStr];
    
    NSMutableArray * newStrAray = [NSMutableArray array];
    
    for (NSString * str in imageStrArray) {
        NSRange range = [str rangeOfString:starSubStr];
        
        if (range.length!=0) {
            NSString * newStr  = [str substringFromIndex:range.location];
            [newStrAray addObject:newStr];
        }
    }
    
    return newStrAray;
}

+(NSMutableArray *)stringWithStr:(NSString *)nsstring ComponentStr:(NSString *)componentStr endSubStr:(NSString *)endSubStr
{
    NSArray * imageStrArray = [nsstring componentsSeparatedByString:componentStr];
    
    NSMutableArray * newStrAray = [NSMutableArray array];
    
    for (NSString * str in imageStrArray) {
        NSRange range = [str rangeOfString:endSubStr];
        
        if (range.length!=0) {
            NSString * newStr  = [str substringToIndex:range.location+range.length];
            [newStrAray addObject:newStr];
        }
    }
    
    return newStrAray;
}

+(NSMutableArray *)stringWithStr:(NSString *)nsstring ComponentStr:(NSString *)componentStr startSubStr:(NSString *)starSubStr endSubStr:(NSString *)endSubStr
{
    NSArray * imageStrArray = [nsstring componentsSeparatedByString:componentStr];
    
    NSMutableArray * newStrAray = [NSMutableArray array];
    
    for (NSString * str in imageStrArray) {
        NSRange range1 = [str rangeOfString:starSubStr];
        NSRange range2 =[str rangeOfString:endSubStr];
        if (range1.length!=0 && range2.length!=0) {
            NSString * newStr  = [str substringToIndex:range2.location+range2.length];
            newStr = [newStr substringFromIndex:range1.location];
            [newStrAray addObject:newStr];
        }
    }
    
    return newStrAray;
}


@end
